<template>
    <div class="tong_wp">
        <el-dialog custom-class="wwww" v-model="isShow" width="300" draggable overflow :show-close="false"
            :close-on-click-modal="false" :close-on-press-escape="false" :append-to-body="false">
            <template #header>
                <span class="eldiao_title">提示</span>
            </template>
            <template #footer>
                <div class="body">{{ msg }}</div>
                <div class="btns">
                    <button @click="sumbit(true)">确认</button>
                    <button v-if="isClose == 2" @click="sumbit(false)">取消</button>
                </div>
            </template>
        </el-dialog>
    </div>
</template>

<script>
export default {
    data() {
        return {
            isShow: false,
            msg: '',
            isClose: 1,
            resolve: null
        };
    },
    methods: {
        open(v, type = 1) {
            this.isShow = true
            this.msg = v
            this.isClose = type
            return new Promise((resolve) => {
                this.resolve = resolve;  // 存储 resolve 函数
            });
        },
        sumbit(result) {
            this.isShow = false;
            if (this.resolve) {
                this.resolve(result);  // 返回 true 或 false
            }
        }
    },
};
</script>

<style scoped lang="less">
.tong_wp {


    .body {
        text-align: left;
        padding: 8px 8px 0;
    }

    .eldiao_title {
        display: inline-block;
        text-align: left;
        padding: 5px;
    }

    :deep(.is-draggable) {
        padding: 0;
        border-radius: 5px 5px;
    }

    :deep(.el-dialog__header) {
        padding: 0;
    }

    :deep(.el-dialog__header.show-close) {
        background-color: #f3f3f3;
        border-radius: 5px 5px 0 0;
        height: 25px;
    }

    :deep(.el-dialog__footer) {
        padding: 0 !important;
    }

    .btns {
        button {
            font-size: 12px;
            margin: 5px 10px 10px;
            width: 80px;
        }
    }
}
</style>
